function Start-PerformanceCounterLog
(
	[System.String[]]$counterSetFilters = $(throw "'counterSetFilters' Specify the counter sets to collect."),
	[System.String]$counterFilePath = $(throw "'counterFilePath' Specify an output performance log binary file without the file extension to save the output to."),
	[System.Int32]$sampleInterval = 15
)
{
	$ErrorActionPreference = "Stop"
	
	$osName = (gwmi -namespace root\cimv2 -class win32_operatingsystem).Name | select-string "Microsoft Windows Server 2008 R2", "Microsoft Windows 7"
	
	if ([System.String]::IsNullOrEmpty($osName) -eq $true)
	{
		write-error "This script is supported on Microsoft Windows Server 2008 R2 and Microsoft Windows 7 operating systems."
	}
	
	if ($counterSetFilters[0] -eq "*")
	{
		write-error "* is not a supported counter set filter."
	}
	
	$counterFilePath = $counterFilePath + ".blg"
	
	$fileExists = test-path $counterFilePath
	
	if ($fileExists -eq $true)
	{
		write-error "The file '$counterFilePath' already exists. Specify a unique file name."
	}
	
	$ErrorActionPreference = "SilentlyContinue"
	
	$counterSets = get-counter -ListSet $counterSetFilters
	write-host "Counter sets that will be captured:" -foregroundColor cyan
	$counterSets | format-table -property CounterSetName
	write-host "Output file: $counterFilePath" -foregroundColor cyan
	write-host "Sample interval: $sampleInterval" -foregroundColor cyan
	write-host "Max file size: $maxFileSize" -foregroundColor cyan
	write-host "Starting collection. Press CTRL+C to stop." -foregroundcolor cyan
	$counterSets | get-counter -continuous -sampleInterval $sampleInterval | export-counter -path $counterFilePath
	write-host "Done" -foregroundColor green
}